﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Public;
using System.Data;

namespace DAL
{
    public class BrandDAL
    {
        DBConnection conn = new DBConnection();
        public DataSet GetAllBrandCBX()
        {
            return conn.LoadDBComBox("SELECT * FROM Brand");
        }
        public DataTable searchBrand(string searchValue)
        {
            return conn.loadData("SELECT * FROM Brand WHERE brandName LIKE '%" + searchValue + "%'");
        }

        public int AddBrand(Brand brand)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@brandName"; value[0] = brand.BrandName;
            return conn.Update("INSERT INTO Brand(brandName) VALUES (@brandName)",
                                    name, value, Nparameter);
        }
        public int UpdateBrand(Brand brand)
        {
            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@brandName"; value[0] = brand.BrandName;
            name[1] = "@brandId"; value[1] = brand.BrandId;
            return conn.Update("UPDATE Brand SET brandName=@brandName WHERE brandId=@brandId",
                                    name, value, Nparameter);
        }
    }
}
